import requests
from bs4 import BeautifulSoup
# import lxml
# https://down.ali213.net/pcgame/all/0-0-0-0-new-pic-3

def onePage(url):
    res = requests.get(url, timeout=1, headers="")
    print(res.content)

    soup = BeautifulSoup(res.content, 'lxml')
    print("---- 华丽的分割线 ----")
    x = soup.select('div[class="famous-ul-container"]')
    x0 = x[0].select('div[class="famous-li"]')
    for xitem in x0:
        xname = xitem.select('div[class="game-name"]')
        strname = xname[0].contents[0]
        print(strname)
        xdetail = xitem.select('a[class="content-a"]')
        strdetail = xdetail[0].attrs['href']
        print(strdetail)
        ximg = xitem.select('a[class="content-a"] > img')
        strimg = ximg[0]
        print(strimg)
        xtags = xitem.select('a[class="content-a"] > div[class="hover-content"] > p > span')
        for xtag in xtags:
            strtag = xtag.contents[0]
            print(strtag, end=',')
        print()
        print()


for i in range(1, 200):
    onePage('https://down.ali213.net/pcgame/all/0-0-0-0-new-pic-{}'.format(i))
# print(x0)

